package com.chanjiedata.changbs.view;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bigkoo.convenientbanner.holder.Holder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chanjiedata.changbs.R;
import com.chanjiedata.changbs.base.MainApplication;
import com.chanjiedata.changbs.help.GlideHelper;
import com.chanjiedata.changbs.net.WebApis;
import com.chanjiedata.changbs.proto.Index;
import com.chanjiedata.changbs.web.ui.WebViewActivity;


/**
 * Created by AndroidIntexh1 on 2018/9/11.
 */

public class BannerImageHoderView implements Holder<Index.get_show_list.List> {
    private ImageView imageView;

    @Override
    public View createView(Context context) {
        //你可以通过layout文件来创建，也可以像我一样用代码创建，不一定是Image，任何控件都可以进行翻页
        imageView = new ImageView(context);
        imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
        return imageView;
    }

    @Override
    public void UpdateUI(Context context, int position, Index.get_show_list.List data) {
//        imageView.setImageResource(R.mipmap.rectangle_default_image);
        GlideHelper.INSTANCE.loadFitXYImage(imageView,data.getAdvCode());
        imageView.setOnClickListener(v -> {
            if (!TextUtils.isEmpty(data.getAdvId())) {  //  关联类型：0无跳转，1链接跳转，2视频详情页跳转
                if (data.getAdvId().contains("http"))  WebViewActivity.startActivity(context, data.getAdvId());
            }
        });
    }
}
